@extends('admin.layout.global')

@section('css-plugins')
@endsection

@section('css')
    <link href="{{ asset('style/admin/css/custom.css') }}" rel="stylesheet">
    <style>
        .pagination {
            margin: 0 0;
        }
    </style>
@endsection

@section('js-plugins')
@endsection

@section('js')
    <script>
        $(function(){
            $('.getShow').click(function(){
                $('#myModal').modal();
                var id = $(this).data('id');
                $("#loader").removeClass('hidden');
                $("#modal_body").addClass('hidden');
                $(".modal-title").text("");
                $.ajax({
                    type:"get",
                    url:"{{ action('Admin\AdminLogController@getShow') }}/"+id,
                    dataType: "json",
                    success:function(result){
                        $("#loader").addClass('hidden');
                        if (result.code == 0) {
                            $(".modal-title").text(result.data.title);
                            $("#user").text(result.data.username);
                            $("#ip").text(result.data.ip);
                            $("#ios_code").text(result.data.iso_code);
                            $("#city").text(result.data.city);
                            if (result.data.origin == null)
                            {
                                $("#origin").addClass('hidden');
                            } else {
                                $("#origin").removeClass('hidden');
                                $("#origin").text(result.data.origin);
                            }
                            if (result.data.ending == null)
                            {
                                $("#ending").addClass('hidden');
                            } else {
                                $("#ending").removeClass('hidden');
                                $("#ending").text(result.data.ending);
                            }
                            $("#created_at").text(result.data.created_at);
                            $("#modal_body").removeClass('hidden');
                        }
                    }
                });
            });
        });
    </script>
@endsection

@section('content')
    <div class="body-content animated fadeIn">
        <div class="row">
            <div class="col-md-12">

                <!-- Start basic color table -->
                <div class="panel">

                    <div class="panel-body no-padding">
                        <div class="table-responsive" style="margin-top: -1px;">
                            <table class="table table-striped table-success">
                                <thead>
                                <tr>
                                    <th class="text-center" width="80">{{ getLang('fieldsAdminLog','type') }}</th>
                                    <th class="text-center">{{ getLang('fieldsAdminLog','event') }}</th>
                                    <th class="text-center">{{ getLang('fieldsAdminLog','performer') }}</th>
                                    <th class="text-center">{{ getLang('fieldsAdminLog','ip') }}</th>
                                    <th class="text-center">{{ getLang('fieldsAdminLog','iosCode') }}</th>
                                    <th class="text-center">{{ getLang('fieldsAdminLog','city') }}</th>
                                    <th class="text-center">{{ getLang('fieldsAdminLog','time') }}</th>
                                    <th class="text-center" width="80">{{ getLang('Tips', 'operation') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($log as $v)
                                    <tr>
                                        <td class="text-center"><span style="color: {{ config('eventType.'.$v->type) ? config('eventType.'.$v->type)['color'] : '#000000' }}">{{ $v->type }}</span></td>
                                        <td class="text-center">{{ Lang::has('event.'.$v->event) ? Lang::get('event.'.$v->event) : $v->event }}</td>
                                        <td class="text-center">{{ getUserName($v->uid) }}</td>
                                        <td class="text-center">{{ $v->ip }}</td>
                                        <td class="text-center">{{ $v->iso_code }}</td>
                                        <td class="text-center">{{ $v->city }}</td>
                                        <td class="text-center">{{ $v->created_at }}</td>
                                        <td class="text-center">
                                            <button data-id="{{ $v->id }}" class="btn btn-primary btn-xs getShow" data-toggle="tooltip" data-placement="top" data-original-title="{{ getLang('Tips', 'show') }}"><i class="fa fa-eye"></i></button>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div><!-- /.table-responsive -->
                    </div><!-- /.panel-body -->
                    <div class="panel-footer">
                        <div class="row">
                            <div class="col-md-12">
                                <div style="text-align: center">
                                    {!! $log->render() !!}
                                </div>
                            </div>
                        </div>
                    </div>
                </div><!-- /.panel -->
                <!--/ End basic color table -->

            </div><!-- /.col-md-12 -->
        </div>
        <!-- Start inside form layout -->
        <div class="modal fade bs-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title"></h4>
                    </div>
                    <div class="modal-body no-padding">
                        <img id="loader" class="center-block hidden" src="{{ asset('style/admin/img/loader.svg') }}" alt="">
                        <div id="modal_body" class="form-body">
                            <div class="row">
                                <div class="col-md-12">
                                    <dl class="dl-horizontal">
                                        <dt>{{ getLang('fieldsAdminLog','performer') }}:</dt><dd id="user"></dd>
                                        <dt>{{ getLang('fieldsAdminLog','ip') }}:</dt><dd id="ip"></dd>
                                        <dt>{{ getLang('fieldsAdminLog','iosCode') }}:</dt><dd id="ios_code"></dd>
                                        <dt>{{ getLang('fieldsAdminLog','city') }}:</dt><dd id="city"></dd>
                                        <dt>{{ getLang('fieldsAdminLog','origin') }}:</dt><dd><pre id="origin"></pre></dd>
                                        <dt>{{ getLang('fieldsAdminLog','ending') }}:</dt><dd><pre id="ending"></pre></dd>
                                        <dt>{{ getLang('fieldsAdminLog','time') }}:</dt><dd id="created_at"></dd>
                                    </dl>
                                </div>
                            </div>
                        </div><!-- /.form-body -->
                        <div class="form-footer">
                        </div><!-- /.form-footer -->
                    </div>

                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
    </div>
@endsection